package com.ruoyi.web.controller.depot;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.depot.domain.LocalInventoryDetails;
import com.ruoyi.depot.service.ILocalInventoryDetailsService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存变动明细Controller
 * 
 * @author luxiaoyu
 * @date 2024-12-20
 */
@RestController
@RequestMapping("/depot/localInventoryDetails")
public class LocalInventoryDetailsController extends BaseController
{
    @Autowired
    private ILocalInventoryDetailsService localInventoryDetailsService;

    /**
     * 查询库存变动明细列表
     */
    @PreAuthorize("@ss.hasPermi('depot:localInventoryDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(LocalInventoryDetails localInventoryDetails)
    {
        startPage();
        List<LocalInventoryDetails> list = localInventoryDetailsService.selectLocalInventoryDetailsList(localInventoryDetails);
        return getDataTable(list);
    }

    /**
     * 导出库存变动明细列表
     */
    @PreAuthorize("@ss.hasPermi('depot:localInventoryDetails:export')")
    @Log(title = "库存变动明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LocalInventoryDetails localInventoryDetails)
    {
        List<LocalInventoryDetails> list = localInventoryDetailsService.selectLocalInventoryDetailsList(localInventoryDetails);
        ExcelUtil<LocalInventoryDetails> util = new ExcelUtil<LocalInventoryDetails>(LocalInventoryDetails.class);
        util.exportExcel(response, list, "库存变动明细数据");
    }

    /**
     * 获取库存变动明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('depot:localInventoryDetails:query')")
    @GetMapping(value = "/{inventoryDetailId}")
    public AjaxResult getInfo(@PathVariable("inventoryDetailId") Long inventoryDetailId)
    {
        return success(localInventoryDetailsService.selectLocalInventoryDetailsByInventoryDetailId(inventoryDetailId));
    }

    /**
     * 新增库存变动明细
     */
    @PreAuthorize("@ss.hasPermi('depot:localInventoryDetails:add')")
    @Log(title = "库存变动明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LocalInventoryDetails localInventoryDetails)
    {
        return toAjax(localInventoryDetailsService.insertLocalInventoryDetails(localInventoryDetails));
    }

    /**
     * 修改库存变动明细
     */
    @PreAuthorize("@ss.hasPermi('depot:localInventoryDetails:edit')")
    @Log(title = "库存变动明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LocalInventoryDetails localInventoryDetails)
    {
        return toAjax(localInventoryDetailsService.updateLocalInventoryDetails(localInventoryDetails));
    }

    /**
     * 删除库存变动明细
     */
    @PreAuthorize("@ss.hasPermi('depot:localInventoryDetails:remove')")
    @Log(title = "库存变动明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inventoryDetailIds}")
    public AjaxResult remove(@PathVariable Long[] inventoryDetailIds)
    {
        return toAjax(localInventoryDetailsService.deleteLocalInventoryDetailsByInventoryDetailIds(inventoryDetailIds));
    }
}
